package main

import (
	"dos_framework/dataServer/heartbeat"
	"dos_framework/dataServer/locate"
	"dos_framework/dataServer/objects"
	"dos_framework/dataServer/temp"
	"log"
	"net/http"
	"os"
)

func main() {
	/*
	*注册处理函数objects.Handler
	*如果客户端访问你本机HTTP服务且URL以“/objects/”开头，那么该请求有objects.Handler处理
	*否则，返回404 Not Found
	 */
	/***
	 * go 语法学习：协程

	 */
	locate.CollectObjects()
	// 启动一个heartbeat协程
	go heartbeat.StartHeartbeat()
	// 启动一个locate协程
	go locate.StartLocate()

	http.HandleFunc("/objects/", objects.Handler)
	http.HandleFunc("/temp/", temp.Handler)
	//监听端口
	log.Fatal(http.ListenAndServe(os.Getenv("LISTEN_ADDRESS"), nil))
}
